<?php
	$search_str="%";
	if(isset($_POST["search_str"])) $search_str="%".$_POST["search_str"]."%";
	$so="0";
	if(isset($_POST["so"])) $so=$_POST["so"];
	
	include("../../include/dbconnect.php");
	
	$table="chungloai";
	session_start();

	header("Content-Type: text/xml");
	echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";
	echo "<$table>";
	
	if(!isset($_SESSION["un"])) $_SESSION["un"]="";
	if($_SESSION["un"]!="")
	{
		$sql="select * from $table where (chophep=1) and (ten like '$search_str')";
		if($so=="1")
		{
			$sql="select $table.* from $table where ($table.chophep=1) and ";
			$sql=$sql."(select count(*) from hang where (hang.idchungloai=$table.id) and ";
			$sql=$sql."(hang.ten like '$search_str'))>0";
		}
		$rs=mysql_query($sql,$conn);
		while($a=mysql_fetch_array($rs))
		{
			echo "<result>";
			echo $a["ten"];
			echo "</result>";
		}
		mysql_free_result($rs);
	}
	
	echo "</$table>";
	include("../../include/dbclose.php");
?>
